package com.bawei.module_detail.model.repository


import com.bawei.lib_net.RetrofitFactory
import com.bawei.module_detail.model.api.DetailApi
import com.bawei.module_detail.model.entity.DanmakuParam
import com.bawei.module_detail.model.entity.SendCommentParam
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn

class DetailRepository {
    val api: DetailApi
    init {
        api= RetrofitFactory.getRetrofitFactory().create(DetailApi::class.java)
    }

    suspend fun getComment(type : Int,itemId:String) = flow {
        emit(api.getComment(type,itemId))
    }.flowOn(Dispatchers.IO)
    suspend fun getSendComment(param : SendCommentParam) = flow {
        emit(api.getSendComment(param))
    }.flowOn(Dispatchers.IO)
    suspend fun getBulletScreenInfo(type : Int,itemId:String) = flow {
        emit(api.getBulletScreenInfo(type,itemId))
    }.flowOn(Dispatchers.IO)
    suspend fun getRecommendSimpleVideo(page : Int,pagesize:Int) = flow {
        emit(api.getRecommendSimpleVideo(page,pagesize))
    }.flowOn(Dispatchers.IO)
    suspend fun getSendBulletScreenInfo(param: DanmakuParam) = flow {
        emit(api.getSendBulletScreen(param))
    }.flowOn(Dispatchers.IO)
}